<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../jquery-3.3.1.min.js"></script>
</head>

<body>
    <script>
        var $$ = function() {};
        $$.prototype = {
            myAjax: function(URL, fn) {
                var xhr = new XMLHttpRequest();
                xhr.onreadystatechange = function() {
                    if (xhr.readyState === 4) {
                        if (xhr.status >= 200 && xhr.status < 300 || xhr.status == 304) {
                            fn(xhr.responseText);
                        } else {
                            alert("错误的文件！");
                        }
                    }
                };
                xhr.open("get", URL, true);
                xhr.send();
            }
        }
        $$ = new $$();
        $$.myAjax('file:////chapter12/data/wangyi.json', function(e) {
            var json = JSON.parse(e);
            console.log(json)
        });
    </script>
</body>

</html>